package com.quitutils.app;

import android.app.Activity;
import androidx.annotation.NonNull;
import com.quitutils.SwipeBackLayout;
import com.quitutils.Utils;

import java.lang.ref.WeakReference;

/**
 * Created by laysionqet on 2018/4/24.
 */
public class SwipeBackListenerActivityAdapter implements SwipeBackLayout.SwipeListenerEx {
    private final WeakReference<Activity> mActivity;
    private SwipBackListener swipBackIml;

    public SwipeBackListenerActivityAdapter(@NonNull Activity activity) {
        mActivity = new WeakReference<>(activity);
    }

    @Override
    public void onScrollStateChange(int state, float scrollPercent) {

    }

    @Override
    public void onEdgeTouch(int edgeFlag) {
        Activity activity = mActivity.get();
        if (null != activity) {
            Utils.convertActivityToTranslucent(activity);
        }
    }

    @Override
    public void onScrollOverThreshold() {

    }

    @Override
    public void onContentViewSwipedBack(int flags) {
        swipBackIml.backSwipFlags(flags);
    }

    public void setSwipListener(SwipBackListener iml){
        this.swipBackIml=iml;
    }

    public interface SwipBackListener{
        void backSwipFlags(int flags);
    }
}
